package be.vdab.dao;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

import be.vdab.entities.Saus;

public class SauzenDAO {
	 private static Map<Long, Saus> sauzen = new ConcurrentHashMap<>();
	  static {
	    sauzen.put(3L, new Saus(3L, "cocktail",Arrays.asList("mayonaise", "ketchup", "cognac")));
	    sauzen.put(6L, new Saus(6L, "mayonaise",Arrays.asList("ei", "mosterd")));
	    sauzen.put(7L, new Saus(7L, "mosterd",Arrays.asList("mosterd", "azijn", "witte wijn")));
	    sauzen.put(12L, new Saus(12L, "tartare",Arrays.asList("mayonaise", "augurk", "tabasco")));
	    sauzen.put(44L, new Saus(44L, "vinaigrette",Arrays.asList("olijfolie", "mosterd", "azijn")));
	  }
	  public Collection<Saus> findAll() {
	    return sauzen.values();
	  }

	
	  
	  public Collection<Saus> findByIngredient(String ingredient) {
		  Collection<Saus> resultaat = new ArrayList<>();
		  for (Saus saus : sauzen.values()) {
			    if ((saus.getIngredienten()).contains(ingredient)) {
			        resultaat.add(saus);
			    }
		  }
		  return resultaat;
	  }
	  
	  public void delete(long nummer) {
		  sauzen.remove(nummer);
	  }


}
